1. Field of the Invention
The present invention relates to a non-volatile semiconductor storage, and more specifically to an improved method for writing and rewriting data in a non-volatile semiconductor storage.
2. Description of Related Art
In the prior art, a disk apparatus used as an external storage for a personal computer mainly includes a hard disk apparatus, a floppy disk apparatus and an optical magnetic disk apparatus. Recently, an external storage composed of a semiconductor memory has been developed. This semiconductor storage is still high in cost per a memory capacity, in comparison with the above mentioned disk apparatuses, but have various advantages that: mechanical parts are a little; it is easy to miniaturize and lighten; a moisture resistance is high; impact resistance is also high; an operation speed is high; and electric power consumption is lower. Therefore, the semiconductor storage is expected to be applied to portable or handy instruments in the form of a memory card including a plurality of semiconductor memories accommodated in a card-shaped housing.
The semiconductor memories constituting the semiconductor storage can roughly be divided into a RAM (random access memory) and ROM (read only memory). The RAM is volatile, and needs a backup power battery in order to continue to maintain stored data. Therefore, consumed electric power increases. On the other hand, the ROM is non-volatile and needs no backup power battery in order to continue to maintain stored data. Therefore, it is optimum to realize a lower electric power consumption. The ROM includes an MROM (Mask ROM), a UVEPROM (Ultra-Violet Erasable and Programmable ROM), and an EEPROM (Electrically Erasable and Programmable ROM).
Of these various types of ROM, the MROM is inexpensive, but is limited in a use extent since it is impossible to rewrite data. The UVEPROM is possible to rewrite data, but is also limited in a use extent, although it has the use extent wider than that of the MROM, since it is necessary to irradiate ultraviolet for erasure of old data prior to a data rewriting. The EEPROM is possible to rewrite data with no necessity of ultraviolet irradiation, and therefore, can be said to be optimum to a semiconductor storage disk.
The EEPROM includes a byte erasure type EEPROM configured to erase data in units of bytes, and a flash type EEPROM capable of erasing all data in the memory chip in bundle or in units of block which are larger than the bytes. This flash type EEPROM will be called simply a "flash memory" hereinafter.
The byte erasure type EEPROM needs an erasure circuit for erasing data in units of bytes, which is more complicated than that of the flash memory, and which requires circuits elements of the number larger than that required in the flash memory. In comparison with the flash memory, therefore, the byte erasure type EEPROM is not suitable in order to realize a large memory capacity of semiconductor storage disk. On the other hand, the flask memory of the type configured to erase all data in the memory chip in bundles has such a disadvantage that, a buffer memory has the same memory capacity as that of the flash memory, in order to save the data not to be rewritten when only a portion of the data is to be rewritten, and therefore, a rewriting time inevitably becomes long. Recently, under these circumstance, it is in many cases that the flash memory of the type configured to erase data in the memory chip in units of blocks, is incorporated into the semiconductor memory disk.
Now, a non-volatile semiconductor storage using the flash memory (called a "semiconductor disk" hereinafter) will be described.
Referring to FIG. 1, there is shown a block diagram illustrating an overall structure of a portable or handy instrument and the semiconductor disk using the flash memory. A semiconductor disk 20 is connected to a portable instrument 21 through an electrical connection means (not shown) such as an electrical connector. The portable instrument 21 includes a central processing unit (CPU) 22, a main memory 23 and peripheral devices 25, which are coupled in common to a bus 24. The bus 24 is connected to the electrical connection means to the semiconductor disk 20.
As shown in FIG. 2, the semiconductor disk 20 includes one or more flash memories 30A to 30C (which are representatively designated by Reference Numeral "30" in this specification), a card controller 31 for controlling all data processings between the portable instrument 21 and the semiconductor disk 20, which are exemplified by a reading of data from the semiconductor disk 20, a writing of data into the semiconductor disk 20 and a rewriting of data in the semiconductor disk 20, and a buffer RAM 33 for temporarily storing the data processed between the portable instrument 21 and the semiconductor disk 20.
In each flash memory 30 mounted on the semiconductor disk 20, as shown in FIG. 3, a chip is divided into one or more blocks 40A to 40F (which are representatively designated by Reference Numeral "40" in this specification). These blocks 40 are so configured that data stored in the flash memory can be erased in units of block, under control of an overall control circuit 42 (for controlling the whole of the flash memory 30) and block control circuits 41A to 41F (which are representatively designated by Reference Numeral "41" in this specification) which are provided for the blocks 40A to 40F, respectively, in a one-to-one relation. Since the overall control circuit 42 and the block control circuits 41 are well known to persons skilled in the art, explanation of a detailed control performed by these control circuits will be omitted.
In a 16 Mbit flash memory, for example, one is so configured that each one erase block is constituted of 64 Kbytes, and another is so configured that each one erase block is constituted of 8 Kbytes.
Ordinarily, the portable instrument 21 and the semiconductor disk 20 are interconnected through a special interface (for example, a disk interface), so that it is an ordinary practice that a data transfer between the portable instrument 21 and the semiconductor disk 20 is performed in units of sector, which is composed of 512 bytes.
Next, a data management in disk apparatuses will be described. An on-disk data structure in a hard disk or a floppy disk is different depending upon an operating system (OS) for supporting the disk apparatus, if it is compared in detail, but a fundamental data structure can be said to be the same. Here, the MS-DOS (Microsoft Disk Operating System) will be described as one example.
In the MS-DOS, as shown in FIG. 4, a storage area 50 on the disk is divided into four areas, namely, a reservation area 51, a FAT (File Allocation Table) area 52, a directory area 53 and a data area 54. Incidentally, a minimum storage unit in the disk is a sector.
When a user uses the disk apparatus, it is unnecessary for the user to know where a file concerned is on the disk. This is all managed by the disk operating system. If a designated file name is given, the disk operating system can know a position within the data area 54 where the file concerned is stored, on the basis of the data in the directory area 53 and the FAT area 52 on the disk.
This method is illustrated in FIG. 5. The directory area 53 stores file names 60 each corresponding to one file and FAT entry numbers 61 each indicating where the corresponding file exists on the disk. Actually, the directory area 53 stores other data including file attribute information, but since information other than the above two kinds of information has no close relation of the subject matter of the present invention, explanation thereof will be omitted.
When the disk operating system prepares the file, the disk operating system allocates the file into the data area 54, not in units of sector, but in units of cluster which has the same size as that of the sector or a size corresponding to a plurality of sectors. Thus, the disk operating system manages the data area 54 by dividing the data area into a plurality of clusters 63A to 63D (which are representatively designated by Reference Numeral "63" in this specification).
If the file is small in size, the file can be stored in only one cluster, but if the file is large in size, a plurality of clusters are required to store the large file. In this time, the clusters storing the large file is not necessarily continuous, and continuity of the clusters storing the large file is indicated by the FAT entry number 61. The FAT area 52 is a set of units which are called "entries 62A to 62D" (which are representatively designated by Reference Numeral "62" in this specification), and each entry 62 corresponds to one cluster in the data area 54, in a one-to-one relation.
Ordinarily, the entry numbers "000" and "001" in the FAT area 52 are not-used areas, and effective entries starts from the entry number "002". The entry number "002" in the FAT area 52 corresponds to a first cluster 63A in the data area 54, and the entry number "003" in the FAT area 52 corresponds to a second cluster 63B in the data area 54.
Each entry 62 in the FAT area 52 indicates a use/empty state of the corresponding cluster and a link status of the file stored. The entry value "000" means that the corresponding cluster is empty, and the entry value "FFF" (in hexadecimal notation) indicates the completion of the file. The entry values "002" to "FF7" means that more than one cluster is required to store the file, and indicates the number of a cluster storing a portion next to a portion stored in the corresponding cluster.
For example, when "FILE-A" is accessed in an example shown in FIG. 5, the "FILE-A" is first searched, and the FAT entry number 61 "003" corresponding to the "FILE-A" is recognized. This means that the "FILE-A" is stored in the cluster corresponding to the FAT entry No. 003.
Next, if the value in the entry No. 003 of the FAT area 52 is investigated, the "FAT entry No. 005" is found. This means that a next cluster storing the "FILE-A" is a cluster corresponding to the FAT entry No. 005.
Succeedingly, the value in the entry No. 005 of the FAT area 52 is investigated. In this case, the "FAT entry No. FFF" is found. As mentioned above, this means the completion of the file. Namely, the "FILE-A" starts from the cluster corresponding to the FAT entry No. 003, and is stored in two clusters corresponding to the "FAT entry Nos. 003 and 005.
Now, an operation of the prior art semiconductor disk will be described with reference to a flow chart of FIG. 6.
As one example, assuming that the semiconductor disk 20 is composed of flash memories which are so configured that each erase block 40 has the size of 512 bytes (one sector) and a unit of one cluster 63 is set to be one sector, a data writing method will be described.
If a data writing command is issued to the semiconductor disk 20 from the portable instrument 21, the card controller 31 recognizes that the data writing command has been issued (Step 70), and confirms a size of data to be written (number of sections) and an area (or address) where the data is to be written (Step 71).
Next, the card controller 31 decides on the basis of the value in the FAT entry 62 of the FAT area 52 for the area where the data is to be written, whether the writing operation is a fresh writing (writing to an empty storage area) or a rewriting (writing to a storage areas to which data has been already written) (Step 72). If the writing operation is the rewriting operation, prior to a writing, the card controller 31 issues an erase instruction for a corresponding cluster 53, to the flash memory 30 (Step 73), and after the completion of the erasing, the card controller 31 executes the writing of the rewrite data (Step 74) and then, completes the operation (Step 77).
On the other hand, when the writing operation is the fresh writing operation, the card controller 31 executes the writing to a corresponding cluster 54 in the flash memory 30 (Step 75), and updates or changes the value in the FAT entry 62 of the FAT area 52 corresponding to the written cluster (Step 76). Then, the operation is completed (Step 77).
One method for realizing the above mentioned operation is disclosed by for example Japanese Patent Application Pre-examination Publication No. JP-A-4-084216 (an English abstract of which is available from the Japanese Patent Office and is incorporated by reference in its entirety into this application). In brief, JP-A-4-084216 proposes a semiconductor disk so configured that each erase block 40 of each flash memory 30 is made the same in size as a sector which is the unit of data reading/writing or a cluster which is the unit of a file allocation, so that the memory capacity of the buffer RAM 33 can be made small or the buffer RAM 33 can be made unnecessary, whereby a data rewriting speed is elevated, with the result that a high speed semiconductor disk is realized.
Furthermore, Japanese Patent Application Pre-examination Publication No. JP-A-1-298600 (an English abstract of which is available from the Japanese Patent Office and is incorporated by reference in its entirety into this application) proposes to an electrically programmable and executable non-volatile semiconductor memory which comprises a block selection circuit for outputting a block selection signal selecting an arbitrary number of blocks to be erased, from a plurality of independently writable and erasable blocks, a storage circuit storing the block selection signal for selecting the arbitrary number of blocks to be erased, and a block erasing circuit for supplying a block erasure signal to the selected blocks.
However, the above mentioned prior arts have the following problems.
A first problem is that it is difficult to realize a large capacity storage by use of the prior art non-volatile semiconductor memory using the flash memory.
The reason for this is that if the sector which is the unit of data reading is caused to correspond to one erase block of the flash memory, the number of erase blocks per a unitary storage capacity in the flash memory becomes remarkably large, with the result that the control circuit for individually controlling each erase block becomes complicated, and the number of circuit elements correspondingly becomes large.
A second problem is that the number of files which can be stored becomes small. The reason for this is that when one erase block of the flash memory is caused to correspond to one cluster which is the unit of a file allocation, not to the sector which is the unit of data reading, in order to overcome the above mentioned first problem, if the size of the cluster is too large, since one cluster is allocated to even a file having the size which does not reach the size of one cluster, the storage area is wasted.
The third problem is that the number of the rewritings of the erase blocks in the flash memory becomes any more than necessary, and therefore, there is possibility that the deterioration of the characteristics of the flash memory is facilitated.
The reason for this is that the flash memory has a lifetime in the number of rewritings. If the number of rewritings exceeds the lifetime, there is an inclination that the speed of the writing and erasing becomes remarkably slow, although a device destroy has not yet occurred. For example, the lifetime in the number of rewritings of the flash memory is said to be on the order of 1,000 to 1,000,000. When the flash memory is used as a storage means, if many erase blocks are required for storing data, the number of blocks required to be erased at the time of the data rewriting becomes large. In addition, if the rewritings are concentrated on a specific limited erase block, the number of the rewritings of the specific limited erase block reaches the lifetime in the number of rewritings earlier than the other erase blocks, with the result that the writing speed of the whole of the memory device becomes late.